package org.example.hotel.controller;

import org.example.hotel.dto.CheckinRequest;
import org.example.hotel.entity.Room;
import org.example.hotel.service.CheckinService;
import org.example.hotel.repository.RoomRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class CheckinController {

    @Autowired
    private CheckinService checkinService;

    @Autowired
    private RoomRepository roomRepository;

    @GetMapping("/remaining-room")
    public List<Room> getRemainingRooms() {
        return roomRepository.findAll();
    }

    @PostMapping("/checkin")
    public String checkin(@RequestBody CheckinRequest request) {
        checkinService.checkin(request);
        return "入住成功";
    }
}
